import { http } from '@/utils/http'
import { AddressItem, AddressParams } from '@/types/address'

// 获取收货地址列表
export const getAddressList = () => {
  return http<AddressItem[]>({
    url: '/member/address'
  })
}

// 新增收货地址
export const addAddress = (data: AddressParams) => {
  return http({
    url: '/member/address',
    method: 'POST',
    data
  })
}

// 根据id查询收货地址
export const getAddressById = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`
  })
}

// 修改收货地址
export const updateAddress = (id: string, data: AddressParams) => {
  return http({
    url: `/member/address/${id}`,
    method: 'PUT',
    data
  })
}

// 删除收货地址
export const delAddressById = (id: string) => {
  return http({
    url: `/member/address/${id}`,
    method: 'DELETE'
  })
}
